<?php
    include("common/function.php");
    include("../config/config.php");
    check_session();

    $module_module=$dbh->query("SELECT * FROM frame_data WHERE type='module'")->fetchAll();
    $module_type=$dbh->query("SELECT * FROM module_type")->fetchAll();
    $select_type1="";
    $select_type2="";
    foreach ($module_type as $value) {
        $select_type1.='<option value="'.$value['type'].'">'.$value['type_name'].'</option>';
        if($value['lavel']=="2"){
            $select_type2.='<option value="'.$value['type'].'">'.$value['type_name'].'</option>';
        }
    }
?>

<!DOCTYPE html>
<!-- saved from url=(0043)http://temporary.com/admin/index/index.html -->
<html class=" js flexbox canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths" lang="" style=""><!--<![endif]--><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>后台管理</title>
        <link rel="icon" type="image/ico" href="/favicon.ico">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
   
        <!-- vendor css files -->
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/font-awesome.min.css">
        <link rel="stylesheet" href="css/jquery.dataTables.min.css">
        <link rel="stylesheet" href="css/datatables.bootstrap.min.css">
        <link rel="stylesheet" href="css/style.css">
        <link rel="stylesheet" href="css/main.css">
        <link rel="stylesheet" href="css/custom.css">
        <link rel="stylesheet" href="css/index.css">
        <link rel="stylesheet" href="/layui/css/layui.css" media="all">
        <!-- vendor css files -->

        <script src="js/jquery-1.8.3.min.js" type="text/javascript"></script>
        <script src="js/jquery.SuperSlide.2.1.1.js"></script>
        <script src="js/uaredirect.js"></script>
        <script type="text/javascript" src="js/receptionframe.js"></script>
        <script type="text/javascript" src="/layer/layer.js"></script>
        <script type="text/javascript" src="/layui/layui.js"></script>
        <!-- project main css files -->


    <style type="text/css">.jqstooltip { position: absolute;left: 0px;top: 0px;visibility: hidden;background: rgb(0, 0, 0) transparent;background-color: rgba(0,0,0,0.6);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000);-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)";color: white;font: 10px arial, san serif;text-align: left;white-space: nowrap;padding: 5px;border: 1px solid white;z-index: 10000;}.jqsfield { color: white;font: 10px arial, san serif;text-align: left;}</style></head>
    <body id="minovate" class="appWrapper device-lg scheme-default default-scheme-color header-fixed aside-fixed rightbar-hidden">
    <div id="wrap" class="animsition fade-in" style="animation-duration: 1.5s;">


<?php  include("common/head.php") ?>       
<?php  include("common/left.php") ?>

<!--/ CONTROLS Content -->

<section id="content">
    <div class="page page-dashboard">
        <div class="pageheader">

            <!-- <h2>后台主页 <span></span></h2> -->

            <div class="page-bar">

                <ul class="page-breadcrumb">
                    <li>
                        <a href="module/home/index.php"><i class="fa fa-home"></i> 起始页</a>
                    </li>
                </ul>

                <div class="page-toolbar">
                    <a role="button" tabindex="0" class="btn btn-lightred no-border">
                        <i class="fa fa-calendar"></i>&nbsp;&nbsp;<span><?php echo date("Y年m月d日");?></span>
                    </a>
                </div>
            </div>

        </div>
        <div style="overflow: hidden;padding:0 10px 0 10px;">
            <!-- 主导航-->
            <div class="navigation">
                <div class="navigation_btn navigation_btn_1" this_module="frame_1">
                Ⅰ级模块
                </div>
                <div class="navigation_btn navigation_btn_2 " this_module="frame_2">
                Ⅱ级模块
                </div>
                <div class="navigation_btn navigation_btn_2 " this_module="frame_3">
                其他设置
                </div>
            <div class="navigation_btn_end" this_module="other"></div></div>
            <!-- 主导航-->
            <!-- 主模块1 -->
            <div class="navigation_module frame_1">

            </div>
            <!-- 主模块1 -->
            <!-- 主模块2 -->
            <div class="navigation_module frame_2">

            </div>
            <!-- 主模块2 -->
            <!-- 主模块3 -->
            <div class="navigation_module frame_3">
                
            </div>
            <!-- 主模块3 -->

        </div>
        <!-- /row -->
    </section>
    <div class="zhemu">
        <div class="show_div">
            <div id="data_id" style="text-align: center;">

            </div>
            <div class="upload_div">
                <div class="upload_btn">
                    <!-- <button type="button" class="layui-btn" id="test1"><i class="layui-icon">&#xe67c;</i>背景图片</button> -->
                </div>
                <div class="upload_show">
                    <!-- <img src="" id="show_pic"> -->
                </div>
            </div>
            <div class="show_item_div">
                <div class="laval_div">
                    <label for="">模块名称</label>
                </div>
                <div class="input_div">
                    <input type="text" id="upload_title">
                </div>
            </div>
            <div class="show_item_div">
                <div class="laval_div">
                    <label for="">模块类型</label>
                </div>
                <div class="select_div lavel1_select">
                    <select name="select_type" id="select_type" onchange="check_type(this.value)">
                    </select>
                </div>
                <div class="laval_div" style="text-align: right;padding-right:10px;">
                    <label for="">状态</label>
                </div>
                <div class="select_div">
                    <select name="select_status" id="select_status" >
                        <option value="1">显示</option>
                        <option value="0">隐藏</option>
                    </select>
                </div>
            </div>
            <div class="show_item_div belong_div" style="display:none;">
                <div class="laval_div" style="text-align: right;padding-right:10px;">
                    <label for="">所属模块</label>
                </div>
                <div class="select_div" >
                    <select name="select_belong" id="select_belong" >
                    <?php
                        if($module_module){
                            foreach ($module_module as $value) {
                                echo '<option value="'.$value['module'].'">'.$value['module_name'].'</option>';
                            }
                        }
                        else{
                            echo '<option value="none">无继承模块</option>';
                        }
                    ?>
                    </select>
                </div>
            </div>
            <div class="show_item_div">
                <div class="laval_div">
                    <label for="">排序</label>
                </div>
                <div class="input_div">
                    <input type="number" id="upload_order" c>
                </div>
            </div>
            <div class="show_item_div url_div">
                <div class="laval_div">
                    <label for="">跳转地址</label>
                </div>
                <div class="input_div">
                    <input  type="text" id="upload_url" placeholder="空置默认为“#”，即不做跳转">
                </div>
            </div>
            <div class="show_item_div">
                <div class="laval_div">
                </div>
                <div class="input_div">
                    <button class="layui-btn" onclick="save_data()" >立即提交</button>
                    <button class="layui-btn layui-btn-primary" onclick="close_shade()">取消关闭</button>
                </div>
            </div>
        </div>
    </div>
<!--/ CONTENT -->

</body>
<script type="text/javascript">
    //初始状态
    $(".receptionframe_").css("background-color","rgba(255, 255, 255, 0.5)");//左侧导航高亮

    function add_module(){
        $("#select_type").html('<?php echo $select_type1;  ?>');
        $("#data_id").html("");
        $("#data_id").attr("");
        $("#upload_title").val("");
        $("#select_type").val("");
        $("#select_status").val("");
        $("#upload_order").val("");
        $("#upload_url").val("");
        $(".belong_div").css("display","none");
        $(".zhemu").css("display","block");
        
    }
    function add_module1(){
        $("#select_type").html('<?php echo $select_type1;  ?>');
        $("#data_id").html("");
        $("#data_id").attr("");
        $("#upload_title").val("");
        $("#select_type").val("");
        $("#select_status").val("");
        $("#upload_order").val("");
        $("#upload_url").val("");
        $(".belong_div").css("display","block");
        $(".zhemu").css("display","block");
        
    }
    function modify_frame(this_){
        $("#select_type").html('<?php echo $select_type1;  ?>');
        var data=this_.split(",");
        $("#data_id").html(data[0]);
        $("#data_id").attr("module",data[1]);
        //$("#show_pic").attr("src",data[1]);
        $("#upload_title").val(data[2]);
        $("#select_type").val(data[3]);
        $("#select_status").val(data[4]);
        $("#upload_order").val(data[5]);
        $("#upload_url").val(data[6]);
        $(".belong_div").css("display","none");
        $(".zhemu").css("display","block");
        check_type(data[3]);
    }
    function modify_frame1(this_){
        $("#select_type").html('<?php echo $select_type2;  ?>');
        var data=this_.split(",");
        $("#data_id").html(data[0]);
        $("#data_id").attr("module",data[1])
        //$("#show_pic").attr("src",data[1]);
        $("#upload_title").val(data[2]);
        $("#select_type").val(data[3]);
        $("#select_status").val(data[4]);
        $("#upload_order").val(data[5]);
        $("#upload_url").val(data[6]);
        $(".belong_div").css("display","none");
        $(".zhemu").css("display","block");
    }

    function close_shade(){
        $(".zhemu").css("display","none");
    }
    function check_type(module_type){
        if(module_type=="turn"){
            $(".url_div").css("display","block");
        }
        else{
            $(".url_div").css("display","none");
        }
    }



//layui框架上传图片
layui.use('upload', function(){
  var upload = layui.upload;
   
  //执行实例
  var uploadInst = upload.render({
    elem: '#test1', //绑定元素
    url: 'upload.php', //上传接口
    accept: 'image',
    size: 20480,
    before: function(obj){ 
        var index1 = layer.load(
            3,
            {shade: [0.5,'#000'] }
        );
  },
    done: function(res){
        layer.closeAll('loading'); //关闭loading
        if(res.code == 0){
            layer.alert("服务器端出错，请稍后再试！");
        }
        else{
            $("#show_pic").attr("src",res.msg);
        }
    },
    error: function(){
        layer.closeAll('loading'); //关闭loading
    }
  });
});
</script>
<script type="text/javascript" src="js/module.js"></script>
</html>